import hashlib

from App.views_constant import SERVER_PORT, SERVER_HOST, EMAIL_HOST_USER


def hash_str(source):
    '''对源密码hash 摘要 加密返回'''
    return hashlib.new('sha512', source.encode('utf-8')).hexdigest()


def send_email_activate(receive, username, u_token):
    subject = '%s AXF Activate' % username
    from_email = EMAIL_HOST_USER
    recipient_list = [receive, ]
    data = {
        'username': username,
        'activate_url': 'http://{}:{}/axf/activate/?u_token={}'.format(SERVER_HOST, SERVER_PORT, u_token)
    }
    #  Django send_mail
    # html_message = loader.get_template('user/activate.html').render(data)
    # send_mail(subject=subject, message='',
    #           html_message=html_message, from_email=from_email, recipient_list=recipient_list)
